package com.valveinspectionsys.routing.activity;

import java.util.List;

import com.valveinspectionsys.R;
import com.valveinspectionsys.dbhelp.XmlNameHelper;
import com.valveinspectionsys.povo.ListViewInfo;
import com.valveinspectionsys.routing.BaseAdapter.DeviceListInfoAdapter;
import com.valveinspectionsys.routing.db.DeviceRoutingDao;
import com.valveinspectionsys.util.SharedPreferenceUtil;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ListView;

/**
 * 保养设备册列表
 * @author King
 *2013-5-5
 */
public class DeviceRoutingListInfo  extends Activity {
                     
    public ListView  listview;
    
    public List<ListViewInfo> items;
    
    public DeviceRoutingDao  dao;
    public SharedPreferenceUtil  sp;
    public DeviceListInfoAdapter adapter;
    public Intent intent=null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
	
	super.onCreate(savedInstanceState);
	setContentView(R.layout.device_list_info);
	sp=new SharedPreferenceUtil(this);
	dao=new DeviceRoutingDao(this,sp.getValue(XmlNameHelper.SqliteName));
	listview = (ListView) this.findViewById(R.id.device_list_info_listView);
	items=dao.queryAllInfoDeviceList();
	adapter=new DeviceListInfoAdapter(items, this);
	listview.setAdapter(adapter);
	listview.setOnItemClickListener(new OnItemClickListener() {

	    @Override
	    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		intent=new Intent(DeviceRoutingListInfo.this, DeviceRoutingCheck.class);
		intent.putExtra("devicelistid", items.get(arg2).getDevicelistid());
		startActivity(intent);
		
	    }
	});
    }
    
    
}
